<html>
<head><meta charset="utf-8"><title>Reducing a 5MB IR file · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Reducing.20a.205MB.20IR.20file.html">Reducing a 5MB IR file</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="247396179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Reducing%20a%205MB%20IR%20file/near/247396179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Reducing.20a.205MB.20IR.20file.html#247396179">(Jul 27 2021 at 21:48)</a>:</h4>
<p>I've ended with a 5MB LLVM IR file (<a href="https://github.com/rust-lang/rust/issues/86758">https://github.com/rust-lang/rust/issues/86758</a>). 'bugpoint' doesn't seem very suitable for reducing this - it only got a fraction of the way through, but started using 9GB of ram. Are there are tools or techniques I could use to reduce this file?</p>



<a name="247396241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Reducing%20a%205MB%20IR%20file/near/247396241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Reducing.20a.205MB.20IR.20file.html#247396241">(Jul 27 2021 at 21:49)</a>:</h4>
<p>I tried to copy just the affected function (as printed by the assert message), but wasn't able to reproduce it.</p>



<a name="247396461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Reducing%20a%205MB%20IR%20file/near/247396461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Reducing.20a.205MB.20IR.20file.html#247396461">(Jul 27 2021 at 21:51)</a>:</h4>
<p>You could try creduce. While it is officially meant for C, it works with anything even remotely C like, including Rust and possibly textual LLVM IR files.</p>



<a name="247397586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Reducing%20a%205MB%20IR%20file/near/247397586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Reducing.20a.205MB.20IR.20file.html#247397586">(Jul 27 2021 at 22:00)</a>:</h4>
<p>You could try using llvm-reduce instead of bugpoint. When using bugpoint, passing <code>-disable-attribute-remove</code> sometimes helps to avoid wasting a lot of time on a pretty useless reduction step.</p>



<a name="247397857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Reducing%20a%205MB%20IR%20file/near/247397857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Reducing.20a.205MB.20IR.20file.html#247397857">(Jul 27 2021 at 22:01)</a>:</h4>
<p>For llvm-reduce you need to provide a separate script as an interestingness test, something along the lines of <code>! build/bin/llc &lt; $1</code>.</p>



<a name="247399186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Reducing%20a%205MB%20IR%20file/near/247399186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Reducing.20a.205MB.20IR.20file.html#247399186">(Jul 27 2021 at 22:13)</a>:</h4>
<p>Wow,  llvm-reduce worked incredibly well</p>



<a name="247399198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Reducing%20a%205MB%20IR%20file/near/247399198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Reducing.20a.205MB.20IR.20file.html#247399198">(Jul 27 2021 at 22:13)</a>:</h4>
<p>it reduced to a 51 line file</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>